package com.jn.zhinongbao.adapter.adapter;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;

import com.example.supportingagriculturaltreasures.fragment.AgricultureFragment;
import com.example.supportingagriculturaltreasures.fragment.HomeFragment;
import com.example.supportingagriculturaltreasures.fragment.MessageFragment;
import com.example.supportingagriculturaltreasures.fragment.ProfileFragment;
import com.example.supportingagriculturaltreasures.fragment.SimpleFragment;

public class MainPagerAdapter extends FragmentStateAdapter {

    public MainPagerAdapter(@NonNull FragmentActivity fragmentActivity) {
        super(fragmentActivity);
    }

    @NonNull
    @Override
    public Fragment createFragment(int position) {
        switch (position) {
            case 0:
                return HomeFragment.newInstance();
            case 1:
                return AgricultureFragment.newInstance();
            case 2:
                return SimpleFragment.newInstance("发布");
            case 3:
                return new MessageFragment();
            case 4:
                return ProfileFragment.newInstance();
            default:
                return HomeFragment.newInstance();
        }
    }

    @Override
    public int getItemCount() {
        return 5;
    }
} 